<?php
class Controller
{
	private $content;
	private $contentView;
	private $action;
	public $data;
	
	public function __construct($action)
	{		
		$this->action = $action;
	}
	
	public function GetContent()
	{
		return $this->content;
	}
	
	public function View($template)
	{
		if ($this->data != null)
		{
			foreach ($this->data as $key => $value)
				${$key} = $value;
		}
		
		include 'Views/'.str_replace('Controller', '', get_class($this)).'/'.$this->action.'View.php';
		$this->content = $content = ob_get_clean();
		
		if (isset($template))
		{
			if ($template=='default')
				$template = 'Default.php';
			
			if ($template == "Error.php")
				$content = $this->data['error'];
				
			include 'Templates/'.$template;
			$this->contentView = ob_get_clean();
			echo $this->contentView;
		}
	}
	
	public function PartialView()
	{
		if ($this->data != null)
		{
			foreach ($this->data as $key => $value)
				${$key} = $value;
		}		
		
		include 'Views/'.str_replace('Controller', '', get_class($this)).'/'.$this->action.'View.php';
		$this->content = $content = ob_get_clean();
		
		echo $content;
	}
	
	public function PartialViewString()
	{
		if ($this->data != null)
		{
			foreach ($this->data as $key => $value)
				${$key} = $value;
		}		
		
		include 'Views/'.str_replace('Controller', '', get_class($this)).'/'.$this->action.'View.php';
		$this->content = $content = ob_get_clean();
		
		return $content;
	}
}
?>